/*
games data

*/

********************************************************************************
******************************* SECTION PARENTS ********************************
********************************************************************************

use "$Baseline_dtRaw/games/150910_CEIS_ParticipantesJogos_EE_Matching.dta", clear



set more off

rename Data 			date
rename Escola 			school_name
rename ID_Escola 		school_id
rename ID_Participante 	resp_idgame
rename Nome 			resp_name
rename Matching 		matched
rename Respondent_ID 	resp_id
rename Nome_Inq 		resp_name_survey
rename ID_Encarregado	resp_idparent

rename Act2_Enviado 		A2_sent
rename Act2_Devolvido		A2_received
rename reclama* 			complain*
rename minimo_nao_reclama 	min_no_complain
rename cartas* 				faces*
rename Act3 				A3
rename Numero_Grupo			expect_group
rename Total_Grupo			true_group

order school_name school_id resp_idgame resp_idparent resp_name resp_name_survey matched resp_id date A2_sent A2_received min_no_complain

lab var school_name 		"Name school"
lab var school_id  			"ID number school"
lab var resp_idgame  		"ID number respondent games (parent)"
lab var resp_idparent  		"ID number within school (parent)"
lab var resp_name  			"Name respondent"
lab var resp_name_survey  	"Name respondent in survey"
lab var matched  			"Matched with survey"
lab var resp_id  			"ID number respondent"
lab var date  				"Date of game"
lab var A2_sent  			"Trust game: Value parent sends to teacher"
lab var A2_received  		"Trust game: Value parent receives from teacher"
lab var min_no_complain  	"Trust game: Minimum the parents wants to receive in order not to complain"
lab var complain0  			"Trust game: Complain if receive 0"
lab var complain200  		"Trust game: Complain if receive 200"
lab var complain400  		"Trust game: Complain if receive 400"
lab var complain600  		"Trust game: Complain if receive 600"
lab var complain800  		"Trust game: Complain if receive 800"
lab var complain1000  		"Trust game: Complain if receive 1000"
lab var complain1200  		"Trust game: Complain if receive 1200"
lab var complain1400  		"Trust game: Complain if receive 1400"
lab var complain1600  		"Trust game: Complain if receive 1600"
lab var complain1800  		"Trust game: Complain if receive 1800"
lab var complain2000  		"Trust game: Complain if receive 2000"
lab var complain2200  		"Trust game: Complain if receive 2200"
lab var complain2400  		"Trust game: Complain if receive 2400"
lab var faces0  			"Trust game: Number of sad faces if receive 0"
lab var faces200  			"Trust game: Number of sad faces if receive 200"
lab var faces400  			"Trust game: Number of sad faces if receive 400"
lab var faces600  			"Trust game: Number of sad faces if receive 600"
lab var faces800  			"Trust game: Number of sad faces if receive 800"
lab var faces1000  			"Trust game: Number of sad faces if receive 1000"
lab var faces1200  			"Trust game: Number of sad faces if receive 1200"
lab var faces1400  			"Trust game: Number of sad faces if receive 1400"
lab var faces1600  			"Trust game: Number of sad faces if receive 1600"
lab var faces1800  			"Trust game: Number of sad faces if receive 1800"
lab var faces2000  			"Trust game: Number of sad faces if receive 2000"
lab var faces2200  			"Trust game: Number of sad faces if receive 2200"
lab var faces2400  			"Trust game: Number of sad faces if receive 2400"
lab var A3  				"Public good game: Contribute to group account"
lab var expect_group  		"Public good game: Expectation about number of other contributions to group account"
lab var true_group 			"Public good game: Actual number of other contributions to group account"

replace min_no_complain = . if A2_sent==0
replace min_no_complain = 400 if min_no_complain==1

foreach var in  complain0 complain200 complain400 complain600 complain800 complain1000 complain1200 complain1400 complain1600 complain1800 complain2000 complain2200 complain2400{
replace `var' = . if A2_sent==0
}
foreach var in complain800 complain1000 complain1200 complain1400 complain1600 complain1800 complain2000 complain2200 complain2400{
replace `var' = . if A2_sent==200
}
foreach var in complain1400 complain1600 complain1800 complain2000 complain2200 complain2400{
replace `var' = . if A2_sent==400
}
foreach var in complain2000 complain2200 complain2400{
replace `var' = . if A2_sent==600
}


foreach var in  faces0 faces200 faces400 faces600 faces800 faces1000 faces1200 faces1400 faces1600 faces1800 faces2000 faces2200 faces2400{
replace `var' = . if A2_sent==0
}
foreach var in  faces800 faces1000 faces1200 faces1400 faces1600 faces1800 faces2000 faces2200 faces2400{
replace `var' = . if A2_sent==200
}
foreach var in faces1400 faces1600 faces1800 faces2000 faces2200 faces2400{
replace `var' = . if A2_sent==400
}
foreach var in faces2000 faces2200 faces2400{
replace `var' = . if A2_sent==600
}

replace A3="" if A3=="-"
replace A3="" if A3=="--"
replace A3="1" if A3=="G"
replace A3="0" if A3=="P"
replace A3="0" if A3=="p"
destring A3, replace

replace expect_group="" if expect_group=="-"
replace expect_group="" if expect_group=="--"
destring expect_group, replace

replace true_group="" if true_group=="-"
replace true_group="" if true_group=="--"
destring true_group, replace

lab def dummy 1 "Yes" 0 "No"

lab val complain* A3 dummy

gen newid = school_id*100
replace newid = newid+resp_idparent
order newid
lab var newid "ID created for easy matching"

save "$Baseline_dtRaw/_intermediate files/baseline_parentsgame.dta", replace


********************************************************************************
******************************* SECTION TEACHERS *******************************
********************************************************************************

use "$Baseline_dtRaw/games/150910_CEIS_ParticipantesJogos_PROF_Matching.dta", clear


rename Data_de_Sessao 		date
rename Escola 				school_name
rename ID_de_Escola 		school_id
rename JOG_PROF 			resp_idgame
rename Matching 			matched
rename Nome_Participante 	resp_name
rename Nome_INQ 			resp_name_survey
rename Respondent_ID 		resp_id
rename ORIGEM				survey
rename Participante			resp_idprof
rename Act1_Mandou			A1
rename Act2_Recebeu 		A2_received
rename Act2_(###)			sent(###)
rename Caras_Recebidas		faces
rename Act3 				A3
rename Numero_G				expect_group
rename Total_G				true_group

order school_name school_id resp_idgame resp_idprof resp_name resp_name_survey survey matched resp_id date A1 A2_received sent* faces A3 expect_group true_group

lab var school_name 		"Name school"
lab var school_id  			"ID number school"
lab var resp_idgame  		"ID number respondent games (professor)"
lab var resp_idprof  		"ID number within school (professor)"
lab var resp_name  			"Name respondent"
lab var resp_name_survey  	"Name respondent in survey"
lab var survey				"Type of survey taken by participant"
lab var matched  			"Matched with survey"
lab var resp_id  			"ID number respondent"
lab var date  				"Date of game"
lab var A1  				"Dictator game: Value teacher sends to parent"
lab var A2_received  		"Trust game: Value teacher receives from parent"
lab var sent200  			"Trust game: Value teacher sends back to parent if received 200"
lab var sent400  			"Trust game: Value teacher sends back to parent if received 400"
lab var sent600  			"Trust game: Value teacher sends back to parent if received 600"
lab var sent800  			"Trust game: Value teacher sends back to parent if received 800"
lab var A3  				"Public good game: Contribute to group account"
lab var expect_group  		"Public good game: Expectation about number of other contributions to group account"
lab var true_group 			"Public good game: Actual number of other contributions to group account"
lab var faces				"Trust game: Faces received"

replace A3="" if A3=="-"
replace A3="" if A3=="--"
replace A3="1" if A3=="G"
replace A3="0" if A3=="P"
destring A3, replace

lab val A3 dummy

gen newid = school_id*100
replace newid = newid+resp_idprof
order newid
lab var newid "ID created for easy matching"

save "$Baseline_dtRaw/_intermediate files/baseline_teachersgame.dta", replace
